<?php
/**
 *
 * User: JSparrow
 * DateTime: 2016/11/22 15:14
 * Created by PhpStorm.
 */

namespace app\modules\admin\controllers;


use app\modules\admin\models\Route;
use Yii;
use yii\filters\VerbFilter;
use yii\web\Controller;

/**
 * 后台首页控制器
 * @package app\modules\admin\controllers
 */
class IndexController extends Controller
{
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'logout' => ['post'],
                ]
            ]
        ];
    }

    public function actionIndex() {
        $routes = new Route();
        return $this->render('index', ['routes' => $routes->getRoutes()]);
    }

    /**
     * 用户注销
     * @return \yii\web\Response
     */
    public function actionLogout() {
        Yii::$app->user->logout();
        return $this->goHome();
    }
}